<template>
    <view class="container">
        <view class="title" style="padding-top: 32rpx;">店铺照片</view>
        <view>
            <tui-upload :value="storePhotovalue" :limit="10" @complete="uploadresult1" @remove="remove">
            </tui-upload>
        </view>
		<view class="title" style="padding-top: 32rpx;">工作环境照片</view>
        <view>
            <tui-upload :value="environmentPhotovalue" :limit="10" @complete="uploadresult2" @remove="remove">
            </tui-upload>
        </view>
		<view class="title" style="padding-top: 32rpx;">员工照片</view>
        <view>
            <tui-upload :value="staffPhotovalue" :limit="10" @complete="uploadresult3" @remove="remove">
            </tui-upload>
        </view>
		<view class="tui-ptop">
			<tui-button type="danger" shadow height="88rpx" shape="circle" @click="submit">保存</tui-button>
		</view>
    </view>

</template>

<script>
const form = require("@/components/common/tui-validation/tui-validation.js")
export default {

    onLoad(options) {
		this.info()
    },
    data() {
        return {
            storePhotovalue: [], //初始化图片,
            storePhoto: [],

			environmentPhotovalue: [], //初始化图片,
            environmentPhoto: [],

			staffPhotovalue: [], //初始化图片,
            staffPhoto: [],
        }
    },
    methods: {
		async info() {
			let _this = this;
			
			let res = await _this.$request.get('adminstore.detail');
			if (res.errno == 0) {
				if (res.data == 0) {
					uni.showModal({
						title: '提示',
						content: res.message,
						showCancel: false,
						//是否显示取消按钮 
						success: function (res) {
							if (res.cancel) { //点击取消,默认隐藏00弹框
							} else {
								uni.reLaunch({
									url: '/pages/login/login?ptype=store'
								});
							}
						}
					});
				} else {
					_this.storePhotovalue = res.data.store_photo;
					_this.storePhoto = res.data.store_photo;

					_this.environmentPhotovalue = res.data.environment_photo;
					_this.environmentPhoto = res.data.environment_photo;

					_this.staffPhotovalue = res.data.staff_photo;
					_this.staffPhoto = res.data.staff_photo;
				}
			}
		},
        uploadresult1: function (e) {
            this.storePhoto = e.imgArr;
        },
		uploadresult2: function (e) {
            this.environmentPhoto = e.imgArr;
        },
		uploadresult3: function (e) {
            this.staffPhoto = e.imgArr;
        },
        remove: function (e) {
            let index = e.index
        },
        submit() { 
            let _this = this;

            let formData = {
                store_photo: _this.storePhoto,
				environment_photo: _this.environmentPhoto,
				staff_photo: _this.staffPhoto,
            }
            _this.$request.post("Adminstore.addPhoto", formData).then((res) => {
                if (res.status == 411) {
                    // 错误 
                    console.log(res.msg)
                    uni.hideLoading();
                    _this.tui.modal('提示', res.msg, false, function (e) {
                        // console.log(e)
                    })

                    return;
                }
                _this.tui.toast('保存成功');
                _this.imgvalue = [];
                // uni.navigateBack()
            }).catch((res) => { })
        }
    }
}
</script>

<style>
page {
    background: #fff;
}

.container {
    background-color: #fff;
    margin-top: 22rpx;
    padding: 30rpx;
    box-sizing: border-box;
    padding-bottom: 162rpx;
}

.title {
    font-size: 30rpx;
    color: #666;
    padding-bottom: 32rpx;
}

.tui-cells {
    border: 1rpx solid #e6e6e6;
    border-radius: 4rpx;
    height: 280rpx;
    box-sizing: border-box;
    padding: 20rpx 20rpx 0 20rpx;
}

.tui-textarea {
    height: 210rpx;
    width: 100%;
    color: #666;
    font-size: 28rpx;
}

.pholder {
    color: #ccc;
}

.textarea-counter {
    font-size: 24rpx;
    color: #999;
    text-align: right;
    height: 40rpx;
    line-height: 40rpx;
    padding-top: 4rpx;
}

.top64 {
    margin-top: 64rpx;
}

.tui-input {
    font-size: 30rpx;
    height: 88rpx;
    border: 1rpx solid #e6e6e6;
    border-radius: 4rpx;
    padding: 0 25rpx;
    box-sizing: border-box;
}

.tui-ptop {
    padding-top: 80rpx;
}
</style>
